package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/3/7
 **/
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos=new FileOutputStream("fos.txt",true);
        String line="总有人不会忘记,那些经历和即将经历。" +
                "从戈壁风,到荒原花," +
                "从山巅雪,到海上月。" +
                "从雷鸣不绝,到雨声不歇。" +
                "心不能竭,人不曾负。" +
                "举目无途,又见归处。";
        byte[] data=line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        fos.write((",我看到过人间无数的奇景,我有着世界上最神奇最有故事的伙伴," +
                "我们在峭壁高歌,在雪山诵经,在戈壁对酒,在海上看月。").getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();
        /*
        FileOutputStream fos=new FileOutputStream("fos.txt",true);
        String line="总有人不会忘记,那些经历和即将经历。" +
                "从戈壁风,到荒原花," +
                "从山巅雪,到海上月。" +
                "从雷鸣不绝,到雨声不歇。" +
                "心不能竭,人不曾负。" +
                "举目无途,又见归处。";
        byte[] data=line.getBytes(StandardCharsets.UTF_8);
        fos.write;
        fos.write((",我看到过人间无数的奇景,我有着世界上最神奇最有故事的伙伴," +
                "我们在峭壁高歌,在雪山诵经,在戈壁对酒,在海上看月。").getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();
         */
    }
}
